package com.suning.command;

import com.suning.constant.Constants;

/**
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 *
 * @author 16080951(林健)
 * @Copyright (c) 2016 苏宁软件技术有限公司 版权所有
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class BaseCommand implements java.io.Serializable {

    private static final long serialVersionUID = 3429582842574093884L;

    //当前页面
    private long currentPage = 1;

    //上一页
    private long prevPage = 0;

    //下一页
    private long nextPage = 0;

    //每页多少条
    private long pageSize = 5;

    //共有多少条
    private long total = 0;

    //是否有上一页
    private boolean hasPrv = false;

    //是否有下一页
    private boolean hasNext = false;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public long getPrevPage() {
        this.prevPage = currentPage - 1;
        return prevPage;
    }

    public void setPrevPage(long prevPage) {
        this.prevPage = prevPage;
    }

    public long getNextPage() {
        this.nextPage = currentPage + 1;
        return nextPage;
    }

    public void setNextPage(long nextPage) {
        this.nextPage = nextPage;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public long getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(long currentPage) {
        this.currentPage = currentPage;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public boolean isHasPrv() {
        //总页数
        long totalPage = total % pageSize == 0 ? total / pageSize : (total / pageSize) + 1;
        if(currentPage <= 1 || currentPage > totalPage ) return false;
        else{
            return true;
        }
    }

    public void setHasPrv(boolean hasPrv) {
        this.hasPrv = hasPrv;
    }

    public boolean isHasNext() {
        //总页数
        long totalPage = total % pageSize == 0 ? total / pageSize : (total / pageSize) + 1;
        if(currentPage >= totalPage) return false;
        else{
            return true;
        }
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }
}
